#!/bin/bash
#
# Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#

# Update apt source list.

readonly DEB_ENTRY=$(installer_get "apt_source_deb")
readonly DEB_SRC_ENTRY=$(installer_get "apt_source_deb_src")

cat > /etc/apt/sources.list <<EOF
## Generated by deepin-installer
${DEB_ENTRY}
${DEB_SRC_ENTRY}
EOF
echo \#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#
echo \# Maker: gfdgd xi、为什么您不喜欢熊出没和阿布呢
echo \# WebSize: https://gfdgd-xi.github.io
echo \# "        " https://gitee.com/gfdgd-xi
echo \# "        " https://github.com/gfdgd-xi
echo \# "        " https://gitlink.org.cn/gfdgd_xi
echo \# Url: https://gitee.com/gfdgd-xi/deepin-installer-for-dclc，https://github.com/gfdgd-xi/deepin-installer-for-dclc，https://gitlink.org.cn/gfdgd_xi/deepin-installer-for-dclc
echo \#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#
# 更新 apt 列表
apt update | true
# 卸载无用程序
# 移除 live cd 维护工具
apt purge uos-livecdtools com.poweriso.spark pardus-boot-repair deepin-repair-tools gparted deepin-community-live-cd-env-install deepin-community-live-cd-appstore grub-customizer deepin-installer -y | true
# 提交安装数
curl http://120.25.153.144/spark-deepin-wine-runner/Install.php?Version=2.3.0 -s > /dev/null | true
curl http://120.25.153.144/spark-simple-remote-desktop-accessor/Install.php?Version=1.2.0-1 -s > /dev/null | true
curl http://120.25.153.144/deepin-live-community-cd-mini-app-store/Install.php?Version=1.5.0-install > /dev/null
# 安装常用软件
apt install cn.wps.wps-office -y
# 判断是否能连接到镜像源
curl https://mirrors.sdu.edu.cn/spark-store-repository --connect-timeout 2 -m 2
if [[ $? == "0" ]]; then
    # 安装星火里面的 QQ、微信（wine 版本）
    # 不使用 aptss，因为在 chroot 环境难以使用
    apt install com.qq.weixin.spark com.qq.im.dwine -y | true
else
    # 安装官方应用商店里面的 QQ、微信（wine 版本）
    apt install com.qq.im.deepin com.qq.weixin.deepin -y | true
fi
# 更新部分程序版本
apt install spark-deepin-wine-runner spark-store com.uostools.udom -y | true
# 安装安卓环境
#apt install com.gitee.uengine.runner.spark -y
# 清除星火应用商店源
rm -rfv /etc/apt/sources.list.d/spark-store.list | true
return 0
